<?php
/**
 * Widget for displaying content of two categories (daul widget) on home page
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage lebanontimes
 * @since Lebanon Times 1.0
 */

include dirname(__FILE__)."/categoryMapping.php";
$thereIsBreakingNews = checkIfThereIsBreakingNews();
?>

<div class="widget daulWidget">
    <div style="background-color: #FFF; width: 100%; height: 45px; clear: both;">
        <div class="tabRight tabActive">
            <?php echo get_the_category_by_ID( $categoryMapping['topnews'][0] );?>
        </div>
        <div class="tabLeft tab">
            آخر الأخبار
        </div>
    </div>
    <div class="contentRight content" style="<?php if (!$thereIsBreakingNews) {echo 'height: 274px;';}?>">
        <ul>
            <?php $posts = get_posts("category={$categoryMapping['topnews'][0]}&numberposts=0");
                foreach($posts as $post) { ?>
                <li><a href="<?php the_permalink() ?>" target="_parent"><?php the_title(); ?></a></li>
            <?php } ?>
        </ul>
    </div>
    <div class="contentLeft content" style="display: none; <?php if (!$thereIsBreakingNews) {echo 'height: 274px;';}?>">
        <ul>
        <?php
            $recent_posts = wp_get_recent_posts();
            foreach( $recent_posts as $recent ){
                echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> ';
            }
        ?>
        </ul>
    </div>
    <div class="footer footerRight">
        <div class="readMore"><a href="<?php echo get_category_link( $categoryMapping['topnews'][0] );?>">إقرأ المزيد</a> <div class="arrow-left"></div></div>
    </div>
    <div class="footer footerLeft" style="display: none;">
        <div class="readMore"><a href="<?php echo esc_url( home_url( '/' ) ); ?>آخر-الأخبار/">إقرأ المزيد</a> <div class="arrow-left"></div></div>
    </div>
</div>